import service from "../utils/request";

/**
 * 获取精灵球列表
 * @param {Object} params 查询参数
 * @param {string} params.query - 搜索关键词
 * @returns {Promise} 精灵球列表数据
 */
export function getPokeballsList(params = {}) {
    return service.get("/pokeballs", { params });
}

/**
 * 搜索精灵球
 * @param {string} query 搜索关键词
 * @returns {Promise} 搜索结果
 */
export function searchPokeballs(query) {
    return service.get("/pokeballs", { params: { query } });
}

/**
 * 根据分类获取精灵球
 * @param {string} category 精灵球分类
 * @returns {Promise} 精灵球列表
 */
export function getPokeballsByCategory(category) {
    return service.get("/pokeballs", { params: { category } });
}

/**
 * 获取模拟精灵球数据（用于后端API不可用时的备用方案）
 * @returns {Promise} 模拟精灵球列表数据
 */
export function getMockPokeballsList() {
    return Promise.resolve({
        flag: true,
        data: [
            {
                id: 1,
                ballId: "pokeball",
                pokeballName: "精灵球",
                description: "用于捕捉野生宝可梦的球。设计简洁，使用方便。",
                imageUrl: "/images/pokeballs/pokeball.png",
                spriteUrl: "/images/pokeballs/sprites/pokeball.png",
                catchRate: 1.0,
                category: "standard"
            },
            {
                id: 2,
                ballId: "great-ball",
                pokeballName: "超级球",
                description: "比精灵球性能更好的球。提高了捕获野生宝可梦的成功率。",
                imageUrl: "/images/pokeballs/great-ball.png",
                spriteUrl: "/images/pokeballs/sprites/great-ball.png",
                catchRate: 1.5,
                category: "standard"
            },
            {
                id: 3,
                ballId: "ultra-ball",
                pokeballName: "高级球",
                description: "性能非常好的球。能够更容易地捕获野生宝可梦。",
                imageUrl: "/images/pokeballs/ultra-ball.png",
                spriteUrl: "/images/pokeballs/sprites/ultra-ball.png",
                catchRate: 2.0,
                category: "standard"
            },
            {
                id: 4,
                ballId: "master-ball",
                pokeballName: "大师球",
                description: "最高性能的球。能够100%捕获任何野生宝可梦。",
                imageUrl: "/images/pokeballs/master-ball.png",
                spriteUrl: "/images/pokeballs/sprites/master-ball.png",
                catchRate: 255.0,
                category: "master"
            },
            {
                id: 5,
                ballId: "safari-ball",
                pokeballName: "狩猎球",
                description: "狩猎区专用的特殊球。只能在狩猎区使用。",
                imageUrl: "/images/pokeballs/safari-ball.png",
                spriteUrl: "/images/pokeballs/sprites/safari-ball.png",
                catchRate: 1.5,
                category: "special"
            },
            {
                id: 6,
                ballId: "net-ball",
                pokeballName: "捕网球",
                description: "对水属性和虫属性的宝可梦特别有效的球。",
                imageUrl: "/images/pokeballs/net-ball.png",
                spriteUrl: "/images/pokeballs/sprites/net-ball.png",
                catchRate: 3.0,
                category: "special"
            },
            {
                id: 7,
                ballId: "dive-ball",
                pokeballName: "潜水球",
                description: "对在水中遇到的宝可梦特别有效的球。",
                imageUrl: "/images/pokeballs/dive-ball.png",
                spriteUrl: "/images/pokeballs/sprites/dive-ball.png",
                catchRate: 3.5,
                category: "special"
            },
            {
                id: 8,
                ballId: "nest-ball",
                pokeballName: "巢穴球",
                description: "对等级较低的宝可梦特别有效的球。",
                imageUrl: "/images/pokeballs/nest-ball.png",
                spriteUrl: "/images/pokeballs/sprites/nest-ball.png",
                catchRate: 1.0,
                category: "special"
            },
            {
                id: 9,
                ballId: "repeat-ball",
                pokeballName: "重复球",
                description: "对已经捕获过的宝可梦特别有效的球。",
                imageUrl: "/images/pokeballs/repeat-ball.png",
                spriteUrl: "/images/pokeballs/sprites/repeat-ball.png",
                catchRate: 3.0,
                category: "special"
            },
            {
                id: 10,
                ballId: "timer-ball",
                pokeballName: "计时球",
                description: "战斗时间越长，捕获率越高的球。",
                imageUrl: "/images/pokeballs/timer-ball.png",
                spriteUrl: "/images/pokeballs/sprites/timer-ball.png",
                catchRate: 1.0,
                category: "special"
            },
            {
                id: 11,
                ballId: "luxury-ball",
                pokeballName: "豪华球",
                description: "能让捕获的宝可梦更容易亲近训练师的球。",
                imageUrl: "/images/pokeballs/luxury-ball.png",
                spriteUrl: "/images/pokeballs/sprites/luxury-ball.png",
                catchRate: 1.0,
                category: "special"
            },
            {
                id: 12,
                ballId: "premier-ball",
                pokeballName: "纪念球",
                description: "购买精灵球时赠送的特殊纪念球。",
                imageUrl: "/images/pokeballs/premier-ball.png",
                spriteUrl: "/images/pokeballs/sprites/premier-ball.png",
                catchRate: 1.0,
                category: "special"
            }
        ],
        msg: "模拟精灵球数据加载成功"
    });
} 